# -*- coding: utf-8 -*-
# desc:同步用例到自动化平台
import requests

BASE_URL = "http://localhost:9999/api/v1"


class Platform():
    def __init__(self):
        self.url = BASE_URL
        self.api_token = "9a4b48444dd46b2f96cfa275e8b3855c"
        self.headers = {
            "api_token": self.api_token
        }

    def sync_testcase(self,param):
        """同步用例到平台"""
        # param = {
        #     "caseid": "2",
        #     "name": "2",
        #     "md5": "222",
        #     "father_md5": "1",
        #     "project_id": 1,
        # }
        res = requests.post(self.url + "/testcase", headers=self.headers, json=param).text
        print(res)

    def sync_testcase_meau(self,param):
        """同步用例目录到平台"""
        # param = {
        #     "name": "321-1",
        #     "md5": "5",
        #     "father_md5": "4",
        #     "project_id":1,
        # }
        res = requests.post(self.url + "/testcase/meau", headers=self.headers, json=param).text
        print(res)


if __name__ == "__main__":
    plat = Platform()
    plat.sync_testcase_meau({"name":"可靠性","md5":5,"father_md5":0,"project_id":1})
